import { queryList, queryHandoverStatus } from '../services';

export default {
    namespace: 'QuitManagement',
    state: {
        quitList: [],
        total: 0,
        pagination: {
            pageSize: 10,
            current: 1,
            total: 0
        },
        quitStatus: null,
        handoverStatus: []
    },

    effects: {
        // 获取列表
        *fetch({ payload, callback }, { call, put }) {
            const response = yield call(queryList, payload);
            yield put({
                type: 'save',
                payload: {
                    // order: payload.orderBy,
                    quitList: response.data.rows,
                    total: response.data.total,
                    pagination: {
                        pageSize: response.data.pageSize,
                        current: response.data.pageNo,
                        total: response.data.total
                    }
                }
            });
            if (callback) {
                callback(response);
            }
        },
        *fetchHandoverStatus({ payload, callback }, { call, put }) {
            console.log('sa');
            const response = yield call(queryHandoverStatus, payload);
            yield put({
                type: 'save',
                payload: {
                    handoverStatus: response.data
                }
            });
            if (callback) {
                callback(response);
            }
        }
    },
    reducers: {
        save(state, { payload }) {
            return {
                ...state,
                ...payload
            };
        }
    }
};
